import Component from '@ember/component';

export default Component.extend({
  classNames: ['item-list'],

  didReceiveAttrs() {
    this._super(...arguments);
    this.items.forEach((item) => {
      if (item.id === this.selectedItem.id) {
        item.isSelected = true;
      }
    });
  },

  didRender() {
    this._super(...arguments);
    this.$('.item-list').scrollTop(this.$('.selected-item').position().top);
  }
});